#ifndef DATAFLOW_GRAPHLINK_H
#define DATAFLOW_GRAPHLINK_H

#include <set>

namespace DataFlow
{

namespace Detail
{

class GraphLink
{
	public:

		typedef void      BaseType;
		typedef GraphLink ThisType;

		int       sourceNode;
		int       sourcePort;
		int       targetNode;
		int       targetPort;
		int       capacity;

		GraphLink(void)
			: sourceNode(-1)
			, sourcePort(-1)
			, targetNode(-1)
			, targetPort(-1)
			, capacity  (-1)
		{
			;
		}
};

inline bool operator < (const GraphLink & lhs, const GraphLink & rhs)
{
	if (lhs.sourceNode != rhs.sourceNode) return (lhs.sourceNode < rhs.sourceNode);
	if (lhs.sourcePort != rhs.sourcePort) return (lhs.sourcePort < rhs.sourcePort);
	if (lhs.targetNode != rhs.targetNode) return (lhs.targetNode < rhs.targetNode);
	if (lhs.targetPort != rhs.targetPort) return (lhs.targetPort < rhs.targetPort);
	return false;
}

struct LinkRefersNode
{
	int node;
	LinkRefersNode(int n) : node(n) { ; }
	bool operator () (const GraphLink & link) const
	{
		return ((link.sourceNode == this->node) || (link.targetNode == this->node));
	}
};

struct LinkRefersNodeInput
{
	int node;
	int port;
	LinkRefersNodeInput(int n, int p) : node(n), port(p) { ; }
	bool operator () (const GraphLink & link) const
	{
		return ((link.targetNode == this->node) && (link.targetPort == this->port));
	}
};

}

}

#endif // DATAFLOW_GRAPHLINK_H
